//
//  PageControlViewController.swift
//  DemoProject
//
//  Created by hao on 2018/7/18.
//  Copyright © 2018年 hao. All rights reserved.
//

import UIKit

class PageControlViewController: BaseTableViewController {

    lazy var pageControl: UIPageControl = {
        let _page = UIPageControl()
        self.tableHeadView.addSubview(_page)
        _page.snp.makeConstraints({ (make) in
            make.bottom.equalTo(-34)
            make.centerX.equalTo(self.tableHeadView)
            make.width.equalTo(120)
            make.height.equalTo(34)
        })
        _page.numberOfPages = 3
        _page.currentPage = 0
        _page.pageIndicatorTintColor = UIColor.blue
        _page.currentPageIndicatorTintColor = UIColor.purple
        return _page
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupData()
        pageControl.addTarget(self, action: #selector(pageControlSwitch), for: .touchUpInside)
    }
    
    @objc private func pageControlSwitch() {
        print(info: pageControl.currentPage)
    }
    
    private func setupData() {
        let titles = ["numberOfPages",
                      "currentPage",
                      "pageIndicatorTintColor",
                      "currentPageIndicatorTintColor",
                      "添加分页控件的监听事件"]
        
        let descArr = ["设置有多少页 默认为0",
                       "设置当前页",
                       "设置页码指示器颜色",
                       "设置当前页码指示器颜色",
                       "[pageControl addTarget:self action:@selector(pageChanged:) forControlEvents:UIControlEventValueChanged];"]
        
        addTitles(titles, footDescs: descArr)
    }

}
